package com.yan.core.handler;

import java.lang.reflect.Method;
import java.util.*;
import java.util.regex.Pattern;

/**
 * 封装 handler 方法相关信息
 *
 * @Author: 汪焰
 * @date: 2020/12/8 14:52
 */
public class HandlerMapping {

    private Object controller;//method.invoke(obj,)

    private Method method;

    private String methodUrl;//spring中url是支持正则的

    private Map<String, Integer> paramIndexMapping;//参数顺序，是为了进行参数绑定，

    private Set<String> security;//权限校验


    public HandlerMapping(Object controller, Method method, String methodUrl) {
        this.controller = controller;
        this.method = method;
        this.methodUrl = methodUrl;
        this.paramIndexMapping = new HashMap<>();
        this.security = new HashSet<>();
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public String getMethodUrl() {
        return methodUrl;
    }

    public void setMethodUrl(String methodUrl) {
        this.methodUrl = methodUrl;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }

    public Set<String> getSecurity() {
        return security;
    }

    public void setSecurity(Set<String> security) {
        this.security = security;
    }
}
